package co.recloud.ariadne.thread;

import co.recloud.ariadne.server.DataServer;
import co.recloud.ariadne.store.HostTable;
import co.recloud.ariadne.store.MemoryStore;

public class CondenserThread implements Runnable {

	public void run() {
		while(true) {
			if(!Main.waitForServiceStatus()) {
				continue;
			}
			if(!Main.waitForIdle()) {
				continue;
			}
			HostTable ht = HostTable.getInstance();
			MemoryStore store = MemoryStore.getStore(ht.getLocalhost().getLocation());
			for(String path : store.getAllPaths()) {
				Main.waitForIdle();
				store.condensePath(path);
			}
			DataServer.condenseCommittedTimes();
		}
	}

}
